﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
using FluentAssertions;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;

namespace DocProcessingWorkFlowScenarios
{
    class BBOS_LoginPage
    {
        public BBOS_LoginPage()
        {
            PageFactory.InitElements(BrowserUtility.Current, this); //
        }

        [FindsBy(How = How.Id, Using = "UserName")]
        private IWebElement userNameField;

        [FindsBy(How = How.Id, Using = "Password")]
        private IWebElement passwordField;

        [FindsBy(How = How.ClassName, Using = "btn-login")]
        private IWebElement submitButton;

        [FindsBy(How = How.XPath, Using = "html/body/div[1]/header/div[1]/h1/a/img")]
        private IWebElement bbosLogo;

        [FindsBy(How = How.XPath, Using = "html/body/div[1]/header/div[2]/p/img")]
        private IWebElement dstLogo;

        [FindsBy(How = How.XPath, Using = "html/body/div/div/div/div/form/div[1]/span")]
        private IWebElement usernameFieldValidation;

        [FindsBy(How = How.XPath, Using = "html/body/div/div/div/div/form/div[2]/span")]
        private IWebElement passwordFieldValidation;

    





        private static IWebDriver driver;

        public static BBOS_LoginPage NavigateTo(IWebDriver webDriver)
        {
            driver = webDriver;
            driver.Navigate().GoToUrl("http://dev.nexdox.com/DocProcessingWorkflow/Session/New");
            var loginPage = new BBOS_LoginPage();
            PageFactory.InitElements(driver, loginPage);
            return loginPage;
        }


        public void EnterUserName(string username)
        {
            userNameField.SendKeys(username);
        }

        public void EnterPassword(string password)
        {
            passwordField.SendKeys(password);
        }

        public void ClickSubmit()
        {
            submitButton.Click();
        }

        public void BBOSLogo()
        {
            Assert.IsTrue(bbosLogo.Displayed);
        }

        public void DSTLogo()
        {
            Assert.IsTrue(dstLogo.Displayed);
        }

        public void UsernameValidation()
        {
            Assert.IsTrue(usernameFieldValidation.Displayed);
        }

        public void PasswordValidation()
        {
            Assert.IsTrue(passwordFieldValidation.Displayed);
        }

        public void BBOSurl()
        {
            BrowserUtility.Current.Url.Contains("http://dev.nexdox.com/DocProcessingWorkflow/Session/New");
        }

        public void TimeWait()
        {
            BrowserUtility.Current.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4));
        }

        public void Dispose()
        {
            BrowserUtility.Current.Dispose();
        }

        public void Close()
        {
            BrowserUtility.Current.Close();
        }   

          public void LoginText()
        {
            Assert.IsTrue(BrowserUtility.Current.PageSource.Contains("LOG IN"), "LOG IN Text text not present");
        }


  

    
    }
}
